package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduSchoolRs.EduSchoolRsKeyVO;
import com.jwsoft.manager.common.vo.eduSchoolRs.EduSchoolRsQueryVO;
import com.jwsoft.manager.common.vo.eduSchoolRs.EduSchoolRsVO;
import com.jwsoft.manager.core.integration.EduSchoolRsIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 学校人数统计网关
 *
 * @author chenzh
 * @since 2023-03-30
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "学校人数统计", description = "学校人数统计")
public class EduSchoolRsController {

    @Autowired
    public EduSchoolRsIntegration eduSchoolRsIntegration;

    @Operation(summary = "学校人数统计分页查询",description = "学校人数统计分页查询")
    @PostMapping(value = "/eduSchoolRs0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduSchoolRsVO>> getList(@RequestBody @Validated EduSchoolRsQueryVO vo) {
        return AppResponse.successData(eduSchoolRsIntegration.getList(vo));
    }

    @Operation(summary = "学校人数统计根据主键查询详情",description = "学校人数统计根据主键查询详情")
    @PostMapping(value = "/eduSchoolRs0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolRsVO> getById(@RequestBody @Validated EduSchoolRsKeyVO vo) {
        return AppResponse.successData(eduSchoolRsIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学校人数统计新增",description = "学校人数统计新增")
    @PostMapping(value = "/eduSchoolRs0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolRsVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduSchoolRsVO vo) {
        return AppResponse.successData(eduSchoolRsIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学校人数统计修改",description = "学校人数统计修改")
    @PostMapping(value = "/eduSchoolRs0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolRsVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduSchoolRsVO vo) {
        return AppResponse.successData(eduSchoolRsIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学校人数统计删除",description = "学校人数统计删除")
    @PostMapping(value = "/eduSchoolRs0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduSchoolRsKeyVO vo) {
        eduSchoolRsIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
}
